namespace Ds.DataBase.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitPowerTreeData : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.KeShis",
                c => new
                    {
                        ksid = c.Int(nullable: false, identity: true),
                        ksmc = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ksid);
            
            CreateTable(
                "dbo.PowerTrees",
                c => new
                    {
                        ptid = c.Int(nullable: false, identity: true),
                        mc = c.String(),
                        uri = c.String(),
                        ptpid = c.Int(nullable: false),
                        ptpath = c.String(),
                    })
                .PrimaryKey(t => t.ptid);
            
            CreateTable(
                "dbo.PowerTreeZhiWeis",
                c => new
                    {
                        PowerTree_ptid = c.Int(nullable: false),
                        ZhiWei_zwid = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.PowerTree_ptid, t.ZhiWei_zwid })
                .ForeignKey("dbo.PowerTrees", t => t.PowerTree_ptid, cascadeDelete: true)
                .ForeignKey("dbo.ZhiWeis", t => t.ZhiWei_zwid, cascadeDelete: true)
                .Index(t => t.PowerTree_ptid)
                .Index(t => t.ZhiWei_zwid);
            
            AddColumn("dbo.JiaoZhiGongInfoes", "UpDateTime", c => c.DateTime(nullable: false));
            AddColumn("dbo.UserInfoes", "zt", c => c.Int(nullable: false));
            AddColumn("dbo.ZhiWeis", "zwpid", c => c.Int(nullable: false));
            AddColumn("dbo.ZhiWeis", "zwpath", c => c.String());
            AddColumn("dbo.ZhiWeis", "keshi_ksid", c => c.Int());
            CreateIndex("dbo.ZhiWeis", "keshi_ksid");
            AddForeignKey("dbo.ZhiWeis", "keshi_ksid", "dbo.KeShis", "ksid");
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.PowerTreeZhiWeis", "ZhiWei_zwid", "dbo.ZhiWeis");
            DropForeignKey("dbo.PowerTreeZhiWeis", "PowerTree_ptid", "dbo.PowerTrees");
            DropForeignKey("dbo.ZhiWeis", "keshi_ksid", "dbo.KeShis");
            DropIndex("dbo.PowerTreeZhiWeis", new[] { "ZhiWei_zwid" });
            DropIndex("dbo.PowerTreeZhiWeis", new[] { "PowerTree_ptid" });
            DropIndex("dbo.ZhiWeis", new[] { "keshi_ksid" });
            DropColumn("dbo.ZhiWeis", "keshi_ksid");
            DropColumn("dbo.ZhiWeis", "zwpath");
            DropColumn("dbo.ZhiWeis", "zwpid");
            DropColumn("dbo.UserInfoes", "zt");
            DropColumn("dbo.JiaoZhiGongInfoes", "UpDateTime");
            DropTable("dbo.PowerTreeZhiWeis");
            DropTable("dbo.PowerTrees");
            DropTable("dbo.KeShis");
        }
    }
}
